package com.atguigu.edu.realtime.dws.function;

import com.atguigu.edu.realtime.common.bean.DwsTrafficForSourcePvBean;
import com.atguigu.edu.realtime.common.util.HBaseUtil;
import com.atguigu.edu.realtime.common.util.RedisUtil;
import io.lettuce.core.api.StatefulRedisConnection;
import org.apache.flink.api.common.functions.RichMapFunction;
import org.apache.flink.configuration.Configuration;
import org.apache.hadoop.hbase.client.AsyncConnection;

public class DimMapFunction extends RichMapFunction<DwsTrafficForSourcePvBean, DwsTrafficForSourcePvBean> {
    AsyncConnection hbaseAsyncConn;
    StatefulRedisConnection<String, String> redisAsyncConn;


    @Override
    public void open(Configuration parameters) throws Exception {
        hbaseAsyncConn= HBaseUtil.getAsyncConnection();
        redisAsyncConn = RedisUtil.getAsyncRedisConnection();
    }

    @Override
    public void close() throws Exception {
        HBaseUtil.closeAsyncConnection(hbaseAsyncConn);
        RedisUtil.closeAsyncRedisConnection(redisAsyncConn);
    }

    @Override
    public DwsTrafficForSourcePvBean map(DwsTrafficForSourcePvBean value) throws Exception {
        //旁路缓存获取维度数据，部分dim数据使用异步操作
        //获取来源维度数据
//        HBaseUtil.readDimAsync(hbaseAsyncConn, Constant.HBASE_NAMESPACE,);
            return null;
    
    }
}
